//
//  UIButton+Ext.m
//  objectAssociation
//
//  Created by chaizhiyong on 14-7-18.
//  Copyright (c) 2014年 chaizhiyong. All rights reserved.
//

#import "UILabel+Ext.h"

@implementation UILabel (Ext)

-(float)heightWithContent:(NSString *)text LineSpacing:(float)spacing{
    
    if (!KCNSSTRING_ISEMPTY(text)) {
       
        float LableWight = self.frame.size.width;
        CGSize size = CGSizeMake(LableWight,CGFLOAT_MAX);//LableWight标签宽度，固定的
        NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc]initWithString:text];
        NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init];
        [paragraphStyle setLineSpacing:spacing];
        [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, text.length)];
        self.attributedText = attributedString;
        CGSize labelSize = [self sizeThatFits:size];
        return labelSize.height;
        
    }else{
        return 0;
    }
}

@end
